﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Ebada.Platform.Model;
using DevExpress.XtraGrid.Columns;
using System.Reflection;
using Ebada.Client;
using DevExpress.XtraGrid.Views.Base;
using Ebada.Client.Platform;
namespace Ebada.Modules.Vehicle
{

    public partial class UCVehicleDriverLicense : DevExpress.XtraEditors.XtraUserControl {
        private GridViewOperation<VehicleDriverLicense> gridViewOperation;

        public event SendDataEventHandler<VehicleDriverLicense> FocusedRowChanged;
        public static bool FirstLoad = false;
        public UCVehicleDriverLicense() 
        {
            InitializeComponent();
           // initColumns();
            gridViewOperation = new GridViewOperation<VehicleDriverLicense>(gridControl1, gridView1, barManager1,new frmVehicleDriverLicenseEdit());
            gridViewOperation.CreatingObjectEvent +=gridViewOperation_CreatingObjectEvent;
            gridView1.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(gridViewOperation_FocusedRowChanged);
            gridViewOperation.BeforeAdd += new ObjectOperationEventHandler<VehicleDriverLicense>(gridViewOperation_BeforeAdd);
            InitData();
        }

        void gridViewOperation_BeforeAdd(object render, ObjectOperationEventArgs<VehicleDriverLicense> e)
        {
            e.Value.FirstDate = DateTime.Now;
            e.Value.EndDate = DateTime.Now;
            e.Value.BeginDate = DateTime.Now;
        }

       

        void gridViewOperation_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) 
        {
            if (FocusedRowChanged != null)
                FocusedRowChanged(gridView1, gridView1.GetFocusedRow() as VehicleDriverLicense);
        }
        


       
        /// <summary>
        /// 设置隐藏列
        /// </summary>
        /// 
       public  void initColumns() 
        {
            
          
        }
      
    
        /// <summary>
        /// 封装了数据操作的对象
        /// </summary>
        [Browsable(false)]
       public GridViewOperation<VehicleDriverLicense> GridViewOperation
       {
            get { return gridViewOperation; }
            set { gridViewOperation = value; }
        }
        /// <summary>
        /// 新建对象设置Key值
        /// </summary>
        /// <param name="newobj"></param>
        void gridViewOperation_CreatingObjectEvent(VehicleDriverLicense newobj)
        {
            //newobj.DriverLicense_ID = Guid.NewGuid().ToString();
           
        }

        public void InitData()
        {
            gridViewOperation.RefreshData("");
        }
       
       

    }
}
